<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>报名界面</title>
    <link href="/static/bootstrap-5.3.3-dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="/static/bootstrap-5.3.3-dist/js/bootstrap.bundle.min.js"></script>
    <style>
        body{
            background-image:url("/static/images/img.png");
        }

        .form-group label {
            display: block;
            margin-bottom: 5px;
        }
        .form-group input,
        .form-group select {
            width: 100%;
            padding: 8px;
            box-sizing: border-box;
        }
        .form-group button {
            width: 100%;
            padding: 10px;
            background-color: #007BFF;
            color: #fff;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        .form-group button:hover {
            background-color: #0056b3;
        }
        .footer {
            text-align: center;
            padding: 1rem 0;
            bottom: 10 px;
            background-color: rgb(56, 54, 54);
            color: white;
        }
    </style>
    <script>
        document.addEventListener('DOMContentLoaded', function () {
            const memberTemplate = document.getElementById('memberTemplate');
            const memberList = document.getElementById('memberList');
            let memberIndex = 0;

            document.querySelector('.add-member').addEventListener('click', function () {
                const clone = memberTemplate.cloneNode(true);
                clone.style.display = '';
                clone.id = '';
                clone.querySelector('.remove-member').addEventListener('click', function () {
                    memberList.removeChild(clone);
                });
                clone.querySelectorAll('input').forEach(input => {
                    input.name = `member${memberIndex++}_${input.className.replace('member-', '')}`;
                });
                memberList.appendChild(clone);
            });

            document.getElementById('scheduleButton').addEventListener('click', function () {
                alert('请选择一个时间段进行预约（此功能为模拟，实际需结合后端服务）');
            });

            document.getElementById('withdrawButton').addEventListener('click', function () {
                alert('您已成功弃赛（此功能为模拟，实际需结合后端服务）');
            });

            // 模拟表单提交
            document.getElementById('registrationForm').addEventListener('submit', function (event) {
                event.preventDefault();
                alert('报名信息已提交（此功能为模拟，实际需结合后端服务）');
            });
        });
    </script>
</head>
<body>
    <div class="container">
    <header class="d-flex flex-wrap justify-content-center py-3 mb-4 border-bottom">
      <a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
        <svg class="bi me-2" width="40" height="32"><use xlink:href="#bootstrap"></use></svg>
        <span class="fs-4">欢迎{{ user.username }}</span>
      </a>
      <ul class="nav nav-pills">
        <li class="nav-item"><a href="{% url 'welcome' %}" class="nav-link">主页</a></li>
        <li class="nav-item"><a class="nav-link active" aria-current="page">比赛报名</a></li>
        <li class="nav-item"><a href="{% url 'bookgame' %}" class="nav-link">比赛预约</a></li>
        <li class="nav-item"><a href="{% url 'signgame' %}" class="nav-link">比赛签到</a></li>
          <li class="nav-item"><a href="{% url 'losegame' %}" class="nav-link">队伍弃赛</a></li>
          <li class="nav-item"><a href="{% url 'infogame' %}" class="nav-link">比赛通知</a> </li>

      </ul>
    </header>
  </div>
    <div class="container">
        {% csrf_token %}
        <h1>企业数字化运营挑战赛报名</h1>
        <ul><li>报名信息：{{ user.profile }}</li></ul>
        <form method="post">
            {% csrf_token %}
            {{ form.as_p }}
            <button type="submit" href="{% url 'profile' %}">报名确定或修改</button>
        </form>
        <h2>团队成员信息<a href="{% url 'member_list' %}">操作</a></h2>
        <form id="registrationForm" method="post">
                <div class="team-members">
            <div class="team-member" id="memberTemplate" style="display: none;">
                <label for="memberName">姓名</label>
                <input type="text" class="name">
                <label for="memberCollege">所属学院</label>
                <input type="text" class="college">
                <label for="memberGrade">所属年级</label>
                <input type="text" class="stuclass">
                <label for="memberId">学号</label>
                <input type="text" class="schoolID">
                <button type="button" class="remove-member">删除</button>
            </div>
            <div id="memberList"></div>
        </div>
        <button type="button" class="add-member">添加团队成员</button>
    </form>
    </div>
    <div class="footer">
        <p>联系地址：中央财经大学信息学院7号楼</p>
        <p>联系邮箱：qiyeyunying@xjtu.edu.cn  &nbsp;&nbsp; 联系电话：029-82656919-801
        </p>
    </div>
</body>
</html>